/*    */ package com.zimbra.cs.redolog.op;
/*    */ 
/*    */ import com.zimbra.common.util.ByteUtil;
/*    */ import com.zimbra.cs.mailbox.Mailbox;
/*    */ import com.zimbra.cs.mailbox.MailboxManager;
/*    */ import com.zimbra.cs.mailbox.MailboxOperation;
/*    */ import com.zimbra.cs.mime.ParsedMessage;
/*    */ import com.zimbra.cs.redolog.RedoLogInput;
/*    */ import com.zimbra.cs.redolog.RedoLogOutput;
/*    */ import com.zimbra.cs.store.Blob;
/*    */ import com.zimbra.cs.store.StoreManager;
/*    */ import java.io.IOException;
/*    */ import java.io.InputStream;
/*    */ import java.util.zip.GZIPInputStream;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class SaveDraft
/*    */   extends CreateMessage
/*    */ {
/*    */   private int mImapId;
/*    */   
/*    */   public SaveDraft()
/*    */   {
/* 42 */     this.mOperation = MailboxOperation.SaveDraft;
/*    */   }
/*    */   
/*    */   public SaveDraft(int mailboxId, int draftId, String digest, int msgSize) {
/* 46 */     super(mailboxId, ":API:", false, digest, msgSize, -1, true, 0, null);
/* 47 */     this.mOperation = MailboxOperation.SaveDraft;
/* 48 */     setMessageId(draftId);
/*    */   }
/*    */   
/*    */   public int getImapId() {
/* 52 */     return this.mImapId;
/*    */   }
/*    */   
/*    */   public void setImapId(int imapId) {
/* 56 */     this.mImapId = imapId;
/*    */   }
/*    */   
/*    */   protected String getPrintableData() {
/* 60 */     return super.getPrintableData() + ",imap=" + this.mImapId;
/*    */   }
/*    */   
/*    */   protected void serializeData(RedoLogOutput out) throws IOException {
/* 64 */     out.writeInt(this.mImapId);
/* 65 */     super.serializeData(out);
/*    */   }
/*    */   
/*    */   protected void deserializeData(RedoLogInput in) throws IOException {
/* 69 */     this.mImapId = in.readInt();
/* 70 */     super.deserializeData(in);
/*    */   }
/*    */   
/*    */   public void redo() throws Exception {
/* 74 */     Mailbox mbox = MailboxManager.getInstance().getMailboxById(getMailboxId());
/*    */     
/* 76 */     StoreManager sm = StoreManager.getInstance();
/* 77 */     Blob blob = null;
/* 78 */     InputStream in = null;
/*    */     try {
/* 80 */       in = this.mData.getInputStream();
/* 81 */       if (this.mData.getLength() != this.mMsgSize) {
/* 82 */         in = new GZIPInputStream(in);
/*    */       }
/* 84 */       blob = sm.storeIncoming(in);
/* 85 */       ParsedMessage pm = new ParsedMessage(blob.getFile(), Long.valueOf(getTimestamp()), mbox.attachmentsIndexingEnabled());
/*    */       
/* 87 */       mbox.saveDraft(getOperationContext(), pm, getMessageId());
/*    */     } finally {
/* 89 */       ByteUtil.closeStream(in);
/* 90 */       sm.quietDelete(blob);
/*    */     }
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/redolog/op/SaveDraft.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */